

--use PolePosition
GO

if EXISTS(SELECT * FROM dbo.sysobjects WHERE id = object_id(N'up_LookupTables_Select') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	DROP PROCEDURE up_LookupTables_Select
GO

CREATE PROCEDURE up_LookupTables_Select
	 @CentralOffice bit = 0 -- Will tb_CentralOffices table be selected? No by default.
	,@DistributionClasses bit = 0 -- Will tb_Distribution_Classes table be selected? No by default.
	,@DistributionLength bit = 0 -- Will tb_Distribution_Lengths table be selected? No by default.
	,@DistributionMeterNote bit = 0 -- Will tb_Distribution_MeterNotes table be selected? No by default.
	,@DistributionPhase bit = 0 -- Will tb_Distribution_Phases table be selected? No by default.
	,@DistributionsTopType bit = 0 -- Will tb_Distributions_TopTypes table be selected? No by default.
	,@Handheld bit = 0 -- Will tb_Handheld table be selected? No by default.
	,@MetersTopType bit = 0 -- Will tb_Meters_TopTypes table be selected? No by default.
	,@RemedyStatus bit = 0 -- Will tb_RemedyStatus table be selected? No by default.
	,@VendorContactType bit = 0 -- Will tb_Vendor_Contact_Types table be selected? No by default.
	,@VendorInspVisitXmissionStructuresInspectionType bit = 0 -- Will tb_Vendor_InspVisit_XmissionStructures_Inspection_Type table be selected? No by default.
	,@VendorInspVisitXmissionStructuresNote bit = 0 -- Will tb_Vendor_InspVisit_XmissionStructures_Notes table be selected? No by default.
	,@VendorInspVisitXmissionStructuresResultType bit = 0 -- Will tb_Vendor_InspVisit_XmissionStructures_ResultTypes table be selected? No by default.
	,@VendorVisitType bit = 0 -- Will tb_Vendor_Visit_Type table be selected? No by default.
	,@XMissionStructuresPoleClasses bit = 0 -- Will tb_XMissionStructures_PoleClasses table be selected? No by default.
	,@XMissionStructuresPoleSpecies bit = 0 -- Will tb_XMissionStructures_PoleSpecies table be selected? No by default.
	,@XMissionStructuresPoleTopType bit = 0 -- Will tb_XMissionStructures_PoleTopTypes table be selected? No by default.
	,@XMissionStructuresPoleTreatment bit = 0 -- Will tb_XMissionStructures_PoleTreatments table be selected? No by default.
	,@XMissionStructuresTopType bit = 0 -- Will tb_XMissionStructures_TopTypes table be selected? No by default.
	,@ReportsProject bit = 0 -- Will tb_Reports_Project table be selected? No by default.
	,@Setting bit = 0 -- Will tb_Settings table be selected? No by default.
	,@UtilityContactType bit = 0 -- Will tb_Utility_Contact_Types table be selected? No by default.
	,@VendorDistributionLookups bit = 0 -- Will tb_Vendor_Distribution_Lookups table be selected? No by default.
AS
	/* 	Initial Generated Date:  Friday, April 03, 2009 
		Purpose: Select one or more lookup tables based on the passed arguments;
	*/

SET NOCOUNT ON	

IF (@CentralOffice = 1)
	SELECT * from v_tb_CentralOffices
	
IF (@DistributionClasses = 1)
	SELECT * from v_tb_Distribution_Classes
	
IF (@DistributionLength = 1)
	SELECT * from v_tb_Distribution_Lengths
	
IF (@DistributionMeterNote = 1)
	SELECT * from v_tb_Distribution_MeterNotes
	
IF (@DistributionPhase = 1)
	SELECT * from v_tb_Distribution_Phases
	
IF (@DistributionsTopType = 1)
	SELECT * from v_tb_Distributions_TopTypes
	
IF (@Handheld = 1)
	SELECT * from v_tb_Handheld
	
IF (@MetersTopType = 1)
	SELECT * from v_tb_Meters_TopTypes
	
IF (@RemedyStatus = 1)
	SELECT * from v_tb_RemedyStatus
	
IF (@VendorContactType = 1)
	SELECT * from v_tb_Vendor_Contact_Types
	
IF (@VendorInspVisitXmissionStructuresInspectionType = 1)
	SELECT * from v_tb_Vendor_InspVisit_XmissionStructures_Inspection_Type
	
IF (@VendorInspVisitXmissionStructuresNote = 1)
	SELECT * from v_tb_Vendor_InspVisit_XmissionStructures_Notes
	
IF (@VendorInspVisitXmissionStructuresResultType = 1)
	SELECT * from v_tb_Vendor_InspVisit_XmissionStructures_ResultTypes
	
IF (@VendorVisitType = 1)
	SELECT * from v_tb_Vendor_Visit_Type
	
IF (@XMissionStructuresPoleClasses = 1)
	SELECT * from v_tb_XMissionStructures_PoleClasses
	
IF (@XMissionStructuresPoleSpecies = 1)
	SELECT * from v_tb_XMissionStructures_PoleSpecies
	
IF (@XMissionStructuresPoleTopType = 1)
	SELECT * from v_tb_XMissionStructures_PoleTopTypes
	
IF (@XMissionStructuresPoleTreatment = 1)
	SELECT * from v_tb_XMissionStructures_PoleTreatments
	
IF (@XMissionStructuresTopType = 1)
	SELECT * from v_tb_XMissionStructures_TopTypes
	
IF (@ReportsProject = 1)
	SELECT * from v_tb_Reports_Project
	
IF (@Setting = 1)
	SELECT * from v_tb_Settings
	
IF (@UtilityContactType = 1)
	SELECT * from v_tb_Utility_Contact_Types
	
IF (@VendorDistributionLookups = 1)
	SELECT * from v_tb_Vendor_Distribution_Lookups
	
GO